package com.moli.iov.down.command.design.factory.param;

import com.moli.iov.down.enums.command.TerminalSettingEnum;
import com.moli.iov.down.command.design.command.param.query.ParamQueryCommand;
import com.moli.iov.down.command.design.command.param.query.impl.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 参数查询 响应解析 工厂
 * </p>
 *
 * @author: zql
 * @Date: 2019/4/26 14:05
 */
public class ParamQueryCommandFactory {

    private static  final Logger logger = LoggerFactory.getLogger(ParamQueryCommandFactory.class);

    private static final Map<String, ParamQueryCommand> PARAM_QUERY_MAP = new HashMap<>();

    static{
        PARAM_QUERY_MAP.put(TerminalSettingEnum.TERMINAL_SERIAL_NUMBER.getFlag(), new GeneralCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.TERMINAL_MODEL.getFlag(), new GeneralCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.SUPPLIER.getFlag(), new GeneralCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.ICCID.getFlag(), new GeneralCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.MSISDN.getFlag(), new GeneralCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.SOFTWARE_VERSION.getFlag(), new GeneralCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.HARDWARE_VERSION.getFlag(), new GeneralCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.VIN.getFlag(), new GeneralCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.IP.getFlag(), new GeneralCommand());

        PARAM_QUERY_MAP.put(TerminalSettingEnum.LEASING_MODE.getFlag(), new LeasingModeCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.PORT.getFlag(), new PortCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.DATA_FREQUENCY.getFlag(), new DataFrequencyCommand());

        PARAM_QUERY_MAP.put(TerminalSettingEnum.BLUETOOTH_NAME.getFlag(), new BluetoothNameCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.BLUETOOTH_MAC.getFlag(), new BluetoothMacCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.BLUETOOTH_PWD.getFlag(), new BluetoothPwdCommand());
        PARAM_QUERY_MAP.put(TerminalSettingEnum.BLUETOOTH_VALID_TIME.getFlag(), new BluetoothValidTimeCommand());
    }

    private ParamQueryCommandFactory() {
    }

    /**
     * 获取 参数查询 响应解析 对象
     * @param command
     * @return
     */
    public static ParamQueryCommand getParamQueryCommand(String command){
        ParamQueryCommand paramQueryCommand = PARAM_QUERY_MAP.get(command);
        if(paramQueryCommand == null){
            logger.error("[参数查询 响应解析 工厂] 终端参数查询结果上报应答  解码 失败，无当前解析 ParamId：{}", command);
        }
        return paramQueryCommand;
    }
}
